import _regeneratorRuntime from "@babel/runtime/regenerator";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";

/**
 * service: 二级域名单点登录配置
 * @date: 2019-6-27
 */
import request from 'utils/request';
import { CPAAS_PLATFORM } from 'utils/config';
import { getCurrentOrganizationId, isTenantRoleLevel } from 'utils/utils';
var organizationId = getCurrentOrganizationId();
/**
 * 查询列表
 * @async
 * @function query
 * @param {Object} params - 查询参数
 */

export function query(_x) {
  return _query.apply(this, arguments);
}
/**
 * 查询列表
 * @async
 * @function query
 * @param {Object} params - 查询参数
 */

function _query() {
  _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(params) {
    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            return _context.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(isTenantRoleLevel() ? "".concat(organizationId, "/") : '', "export-task"), {
              method: 'GET',
              query: params
            }));

          case 1:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));
  return _query.apply(this, arguments);
}

export function cancel(_x2) {
  return _cancel.apply(this, arguments);
}
/**
 * 查询列表
 * @async
 * @function query
 * @param {Object} params - 查询参数
 */

function _cancel() {
  _cancel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(params) {
    return _regeneratorRuntime.wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            return _context2.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(isTenantRoleLevel() ? "".concat(organizationId, "/") : '', "export-task/cancel"), {
              method: 'PUT',
              query: params
            }));

          case 1:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2);
  }));
  return _cancel.apply(this, arguments);
}

export function download(_x3) {
  return _download.apply(this, arguments);
}

function _download() {
  _download = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(params) {
    var downloadUrl, taskName;
    return _regeneratorRuntime.wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            downloadUrl = params.downloadUrl, taskName = params.taskName;
            return _context3.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(isTenantRoleLevel() ? "".concat(organizationId, "/") : '', "export-task/download"), {
              method: 'POST',
              query: {
                downloadUrl: downloadUrl,
                fileName: taskName
              }
            }));

          case 2:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee3);
  }));
  return _download.apply(this, arguments);
}